<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Mail;

/**
 * data name code email title
 * @return null
 */
class SendMail extends Controller
{
    public function send($name, $email, $title)
    {


        // 验证码长度
        $codelength = '6';

        // 准备验证码随机数
        $rand = rand(pow(10,($codelength-1)), pow(10,$codelength)-1);

        // 发送邮箱
        Mail::send('EmailConten',['name'=>$name, 'code' => $rand],function($message) use ($title, $email){
            $message->to($email)->subject($title);
        });

        // 返回验证信息
        $result = ['type' => 4, 'end_time' => time() + 120, 'code' => $rand];
        return $result;

    }
}
